package com.jt.controller;

import com.jt.pojo.User;
import com.jt.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("ajax")
public class UserController {
    @Autowired
    private UserService userService;

    //http://localhost:8090/ajax/findById?id=1
    @GetMapping("findById")
    public User findById(Integer id){
        return userService.findById(id);
    }

    @GetMapping("findByAS")
    public List<User> findByAs(User user){
        return userService.findByAS(user);
    }
    @GetMapping("findAll")
    public List<User> findAll(){
        return userService.findAll();
    }
    @PostMapping("addUser")
    public void addUser(@RequestBody User user){
         userService.addUser(user);
    }
    @PutMapping("updateUser")
    public void updateUser(@RequestBody User user){
        userService.updateUser(user);
    }
    @DeleteMapping("deleteUser")
    public void deleteUser(User user){
        userService.deleteUser(user);
    }

}
